

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>配额管理 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="CephFS 健康消息" href="../health-messages/" />
    <link rel="prev" title="FS volumes and subvolumes" href="../fs-volumes/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../">Ceph 文件系统</a> &raquo;</li>
        
      <li>配额管理</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/cephfs/quota.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id4">管理</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../createfs/"> 创建 CephFS 文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../administration/"> 管理命令</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multifs/"> 创建多个文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-remove-mds/"> 配备、增加、删除 MDS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/">术语</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds">MDS 守护进程的引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#id3">故障切换的管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-standby-replay">热备的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-join-fs">配置 MDS 与文件系统的亲和性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cache-configuration/"> MDS 缓存配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-config-ref/"> MDS 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-mds/"> ceph-mds 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nfs/"> 通过 NFS 导出</a></li>
<li class="toctree-l3"><a class="reference internal" href="../app-best-practices/"> 应用最佳实践</a></li>
<li class="toctree-l3"><a class="reference internal" href="../fs-volumes/"> FS 卷和子卷</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> CephFS 配额管理</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id2">局限性</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">配置</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../health-messages/"> 健康消息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/">升级 MDS 集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/#firefly-jewel">升级比 Firefly 老的文件系统，需过 Jewel 这个槛</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-top/"> CephFS Top 工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snap-schedule/"> 定时快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-mirroring/"> CephFS 快照镜像</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="id1">
<h1>配额管理<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>CephFS 允许给系统内的任意目录设置配额，这个配额可以限制目录树中这一点以下的<em>字节</em>数或者<em>文件</em>数。</p>
<div class="section" id="id2">
<h2>局限性<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li><p><em>配额是合作性的、非对抗性的。</em> CephFS 的配额功能依赖于挂载它的客户端的合作，
在达到上限时要停止写入；
无法阻止篡改过的或者对抗性的客户端，
它们可以想写多少就写多少。
在客户端完全不可信时，用配额防止多占空间是靠不住的。</p></li>
<li><p><em>配额是不准确的。</em> 在达到配额限制一小段时间后，
正在写入文件系统的进程才会被停止。
很难避免它们超过配置的限额、
多写入一些数据。会超过配额多大幅度主要取决于时间长短，
而非数据量。一般来说，
超出配置的限额之后 10 秒内，
写入会被停掉。</p></li>
<li><p><em>内核客户端在 4.17 及更高版才实现配额功能。</em>
用户空间客户端（ libcephfs 、 ceph-fuse ）早已支持配额了；
&gt;=4.17 的 Linux 内核客户端也支持配额，但仅在
mimic 及更高版本的集群上支持。内核客户端（即使是最近的版本），
即使它们能设置配额扩展属性，也不能处理老集群上的配额。</p></li>
<li><p><em>基于路径限制挂载时必须谨慎地配置配额。</em>
客户端必须能够访问配置了配额的那个目录的索引节点，
这样才能执行配额管理。如果某一客户端被 MDS 能力限制成了只能访问一个特定路径（如 <code class="docutils literal notranslate"><span class="pre">/home/user</span></code> ），
并且它们无权访问配置了配额的父目录（如 <code class="docutils literal notranslate"><span class="pre">/home</span></code> ），
这个客户端就不会按配额执行。所以，
基于路径做访问控制时，最好在限制了客户端的那个目录
（如 <code class="docutils literal notranslate"><span class="pre">/home/user</span></code> ）、或者它下面的子目录上配置配额。</p></li>
<li><p><em>此后删除或更改的快照文件数据不计入配额。</em>
另见 <a class="reference external" href="http://tracker.ceph.com/issues/24284">http://tracker.ceph.com/issues/24284</a> 。</p></li>
</ol>
</div>
<div class="section" id="id3">
<h2>配置<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>就像 CephFS 里的其它配置一样，配额也是用虚拟扩展属性来配置的：</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.quota.max_files</span></code> – 文件限额</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.quota.max_bytes</span></code> – 字节数限额</p></li>
</ul>
</div></blockquote>
<p>如果这些属性出现在目录索引节点里，就意味着那里配置了配额；
如果不存在，那么那个目录就没设置配额
（然而父目录仍然有可能配置了）。</p>
<p>要设置配额：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">setfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_bytes</span> <span class="o">-</span><span class="n">v</span> <span class="mi">100000000</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>     <span class="c1"># 100 MB</span>
<span class="n">setfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_files</span> <span class="o">-</span><span class="n">v</span> <span class="mi">10000</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>         <span class="c1"># 10,000 files</span>
</pre></div>
</div>
<p>要查看设置的配额：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">getfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_bytes</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>
<span class="n">getfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_files</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>
</pre></div>
</div>
<p>需要留意的是，如果这些扩展属性的值是 <code class="docutils literal notranslate"><span class="pre">0</span></code> ，
就说明没设置配额。</p>
<p>要删除配额：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">setfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_bytes</span> <span class="o">-</span><span class="n">v</span> <span class="mi">0</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>
<span class="n">setfattr</span> <span class="o">-</span><span class="n">n</span> <span class="n">ceph</span><span class="o">.</span><span class="n">quota</span><span class="o">.</span><span class="n">max_files</span> <span class="o">-</span><span class="n">v</span> <span class="mi">0</span> <span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="nb">dir</span>
</pre></div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../health-messages/" class="btn btn-neutral float-right" title="CephFS 健康消息" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../fs-volumes/" class="btn btn-neutral float-left" title="FS volumes and subvolumes" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>